{%- if 'cpurad_slot_b_partition' in target['dt'].chosen_nodes['zephyr,code-partition'].labels %}
{%- set mpi_radio_vendor_name = sysbuild['config']['SB_CONFIG_SUIT_MPI_RAD_LOCAL_2_VENDOR_NAME']|default('nordicsemi.com') %}
{%- set mpi_radio_class_name = sysbuild['config']['SB_CONFIG_SUIT_MPI_RAD_LOCAL_2_CLASS_NAME']|default('nRF54H20_sample_rad_local_2') %}
{%- else %}
{%- set mpi_radio_vendor_name = sysbuild['config']['SB_CONFIG_SUIT_MPI_RAD_LOCAL_1_VENDOR_NAME']|default('nordicsemi.com') %}
{%- set mpi_radio_class_name = sysbuild['config']['SB_CONFIG_SUIT_MPI_RAD_LOCAL_1_CLASS_NAME']|default('nRF54H20_sample_rad') %}
{%- endif %}
{%- set suit_artifacts_base_dir = ( target['binary'].split('/')[:-1] | join('/') ) %}
{%- if 'CONFIG_SUIT_ENVELOPE_TARGET_ENCRYPT' in target['config'] and target['config']['CONFIG_SUIT_ENVELOPE_TARGET_ENCRYPT'] != '' %}
  {%- set encrypted = True %}
  {%- set rad_encryption_dir = ( suit_artifacts_base_dir ) + "/" + ( target['name'] ) + "_encryption_artifacts" %}
{%- else %}
  {%- set encrypted = False %}
{%- endif %}

SUIT_Envelope_Tagged:
  suit-authentication-wrapper:
    SuitDigest:
      suit-digest-algorithm-id: cose-alg-sha-256
  suit-manifest:
    suit-manifest-version: 1
{%- if RAD_LOCAL_1_SEQ_NUM is defined %}
    suit-manifest-sequence-number: {{ RAD_LOCAL_1_SEQ_NUM }}
{%- elif DEFAULT_SEQ_NUM is defined %}
    suit-manifest-sequence-number: {{ DEFAULT_SEQ_NUM }}
{%- else %}
    suit-manifest-sequence-number: 1
{%- endif %}
    suit-common:
      suit-components:

      {%- set component_index = 0 %}
      {%- set ACTIVE_IMG_IDX = component_index %}
      - - MEM
        - {{ target['dt'].label2node['cpu'].unit_addr }}
        - {{ get_absolute_address(target['dt'].get_node('suit-active-code-partition')) }}
        - {{ target['dt'].get_node('suit-active-code-partition').regs[0].size }}

      {%- set component_index = component_index + 1 %}
      {%- set INACTIVE_IMG_IDX = component_index %}
      - - MEM
        - {{ target['dt'].label2node['cpu'].unit_addr }}
        - {{ get_absolute_address(target['dt'].get_node('suit-inactive-code-partition')) }}
        - {{ target['dt'].get_node('suit-inactive-code-partition').regs[0].size }}

      suit-shared-sequence:
      - suit-directive-set-component-index: [{{ ACTIVE_IMG_IDX }}, {{ INACTIVE_IMG_IDX }}]
      - suit-directive-override-parameters:
          suit-parameter-vendor-identifier:
            RFC4122_UUID: {{ mpi_radio_vendor_name }}
          suit-parameter-class-identifier:
            RFC4122_UUID:
              namespace: {{ mpi_radio_vendor_name }}
              name: {{ mpi_radio_class_name }}
          suit-parameter-image-digest:
            suit-digest-algorithm-id: cose-alg-sha-256
            suit-digest-bytes:
{%- if encrypted %}
              file_direct: {{ rad_encryption_dir }}/plain_text_digest.bin
{%- else %}
              file: {{ target['binary'] }}
{%- endif %}
          suit-parameter-image-size:
{%- if encrypted %}
            file_direct: {{ rad_encryption_dir }}/plain_text_size.txt
{%- else %}
            file: {{ target['binary'] }}
{%- endif %}
      - suit-condition-vendor-identifier: []
      - suit-condition-class-identifier: []

    suit-validate:
    - suit-directive-set-component-index: {{ INACTIVE_IMG_IDX }}
    # Declare inactive radio partition as IPUC
    # This has to be done here to handle the case in which the
    # radio for both A and B slots is damaged - the IPUC
    # for the inactive radio component still has to be declared.
    - suit-directive-override-parameters:
        suit-parameter-image-size:
          raw: 0
    - suit-directive-set-component-index: {{ ACTIVE_IMG_IDX }}
    - suit-condition-image-match: []

    suit-invoke:
    - suit-directive-set-component-index: {{ INACTIVE_IMG_IDX }}
    # Declare inactive application partition as IPUC
    - suit-directive-override-parameters:
        suit-parameter-image-size:
          raw: 0
    - suit-directive-set-component-index: {{ ACTIVE_IMG_IDX }}
    - suit-directive-invoke: []

{%- if RAD_LOCAL_1_VERSION is defined %}
    suit-current-version: {{ RAD_LOCAL_1_VERSION }}
{%- elif DEFAULT_VERSION is defined %}
    suit-current-version: {{ DEFAULT_VERSION }}
{%- endif %}

    suit-payload-fetch:
    - suit-directive-set-component-index: {{ ACTIVE_IMG_IDX }}
    - suit-directive-override-parameters:
        suit-parameter-uri: "file://{{ target['filename'] }}"
{%- if encrypted %}
        suit-parameter-encryption-info:
          file: {{ rad_encryption_dir }}/suit_encryption_info.bin
{%- endif %}
    - suit-directive-try-each:
      - - suit-condition-image-match: []
      - - suit-directive-fetch: []
        - suit-condition-image-match: []

    suit-install:
    - suit-directive-set-component-index: {{ ACTIVE_IMG_IDX }}
    - suit-condition-image-match: []

    suit-candidate-verification:
    - suit-directive-set-component-index: {{ ACTIVE_IMG_IDX }}
    - suit-condition-image-match: []

    suit-manifest-component-id:
    - INSTLD_MFST
    - RFC4122_UUID:
        namespace: {{ mpi_radio_vendor_name }}
        name: {{ mpi_radio_class_name }}
